
AddCSLuaFile()



ENT.PrintName		= "Shield battery"
ENT.Author			= "Mrannoyus"
ENT.Information		= "Increases shield by 5"
ENT.Category		= "Shields"
ENT.Base 			= "base_gmodentity"
ENT.Editable			= true
ENT.Spawnable			= true
ENT.AdminOnly			= true


function ENT:SetupDataTables()

end

-- This is the spawn function. It's called when a client calls the entity to be spawned.
-- If you want to make your SENT spawnable you need one of these functions to properly create the entity
--
-- ply is the name of the player that is spawning it
-- tr is the trace from the player's eyes 
--
function ENT:SpawnFunction( ply, tr, ClassName )

	if ( !tr.Hit ) then return end
	
	local SpawnPos = tr.HitPos + tr.HitNormal * 3
	
	local ent = ents.Create( ClassName )
		ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	
	return ent
	
end





--[[---------------------------------------------------------
   Name: Initialize
-----------------------------------------------------------]]
function ENT:Initialize()

	self:SetModel("models/Items/battery.mdl") 
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
	self.CanHurt = true
	local phys = self:GetPhysicsObject()

	if phys and phys:IsValid() then
		phys:Wake()
	end
	
end




--[[---------------------------------------------------------
   Name: OnTakeDamage
-----------------------------------------------------------]]
function ENT:OnTakeDamage( dmginfo )

	-- React physically when shot/getting blown
	self:TakePhysicsDamage( dmginfo )
	
end


--[[---------------------------------------------------------
   Name: Use
-----------------------------------------------------------]]
function ENT:Use( activator, caller )

	
	if ( activator:IsPlayer() ) then
		if ( ( activator.shieldMax or 0 ) > 0 && ( activator.shieldEnabled or 0 ) == 1) then
			
			activator.shieldMax = activator.shieldMax + 5
			self:Remove()
		end
		
	end

end


function ENT:Draw()
	self:DrawModel()
end